private var opened:boolean = false;

function Awake()
{
  //Pone la puerta invisible
	GameObject.Find("MeshPuerta").renderer.enabled = false;
}

function OnTriggerEnter(collider: Collider) {
  
	Debug.Log("tocando la puerta, pero está " + (opened==true?"abierta":"cerrada"));
	
	if (opened == true)
	{
		var levelName:String = Application.loadedLevelName;
		
		if (levelName == "Level1")
			Application.LoadLevel("Level2");
		else if (levelName == "Level2")
			Application.LoadLevel("Level3");
		else if (levelName == "Level3")
			Application.LoadLevel ("MenuScene"); 
	}
	
}

function Open()
{
	opened = true;
  
  //Pone invisible la puerta
	GameObject.Find("MeshPuerta").renderer.enabled = true;
}

function Update () {
	
}